The purpose of this guided tour is to show some of the debugger capabilities.
1. Open the Debugger: menu Start / Programs / VB Watch 2 / VB Watch Debugger.
2. Click the Options button and make sure the Debugging for quick tour plan is selected.
3. Now click the Debug Project... button on the left and browse for \Program Files\VB Watch 2\Samples\VB6\Debugger Sample\Sample Group.vbg.
4. After instrumentation, the sample loads and a Sample.exe tab appears in the debugger, as well as a HProgressBar.ocx tab. This is because the sample created a HProgressBar object , the progress bar that you can see in the top right corner of the sample window.
5. You can see that every line of code executed is displayed in the debugger windows. The process is slow because the debugger must refresh the display after each line. You can speed it up by clicking the "Refresh every..." box with a value around 1000 ms.
6. The Trace window
Look at the Trace window (with the Common tab selected). You can see the interaction between the exe and the ocx (each is displayed in its own color). Procedures calls are displayed with the value of the arguments passed.
Click the Start button on the sample form to see more interaction. Click Stop.
7. The Threads window
The Threads window reminds which are the active threads.
8. The Debug window
Click the Sample.exe tab. In this view, only informations regarding sample.exe are displayed.
The Debug window outputs the Debug.Print messages. Move the mouse over the progress bar for example.
9. The Call Stack window
Click the Call some procedures button from the sample form and look at the Call Stack window, then click OK.
10. The Instances window
Click the Create some classes button and look at the Instances window.
Instances of all forms/classes/user-controls of the project are displayed with the procedure where they were created. You can check that they are 2 instances of the ocx created (one on each sample form) by selecting the HProgressBar.ocx tab.
Click OK and get back to the Common tab: the Instances window displays the instances history.
11. The Variables window
Click the Change Var buttons and see how variable values are updated. There is one public variable of a form and one public variable of a module.
You can see how the memory used by the process (exe+ocx) behaves over time. Move the mouse over a bar to see where it was measured.
13. The Source code window
This is a representation of the original source code. You can follow the execution here, or set breakpoints.
A funny thing: make sure the Track execution button is pressed in the Source Code window, uncheck the Refresh every... button in the top toolbar, and click the Start button of the sample. You see the code as it is executed. Of course it is slow because it is refreshed after each line execution.
14. Take control of the execution
Now click the Break manually button in the Debugger's toolbar or press the Break key. This will stop the execution of the sample next time an instruction is executed.
For example, click the Create some classes button again. The execution breaks at "SAMPLE.exe | Entering: frmSample.Command5_Click()" (look at the toolbar), which means that we just entered the Command5_Click procedure. Please note that we automatically switched to the Sample.exe tab.
Click the Continue until next line button or press F8. "Executing: Set c1 = New clsSample" displays. This line is not executed yet, but will be the next. Press F8 again (note that a new instance of clsSample appears in the Instances window).
Go on with some F8 or Shift F8 sequences (shortcut for "Continue until next procedure").
When you want to continue the execution normally, press the Continue button or F5.
15. Wait there's more !
In almost every window we've seen, you can right click on an element and locate it in your original source, or in other windows of the Debugger !
16. Trace again
Finally, click the button in the Code that misbehaves when compiled section.
The program seems to hang on but you can see that it actually goes into a never ending loop of "v = v + Val(mArray(x))" / "Next x". Yet if you execute the source code of this test application in the IDE, you'll see that the program does NOT hang !! For that, load the \Program Files\VB Watch 2\Samples\VB6\Debugger Sample\Sample Group.vbg project group and execute it.
These kinds of problems are very difficult and very long to diagnose without a tool like the VB Watch Debugger.
You must now press CTRL ALT DEL and end the Sample task manually.
|
|
|
Step by step: How to use the VB Watch Debugger on your projects |
|
Step by step: How to debug an application running at a remote site |